$(function() {
	if ($('div.form_search_outer').attr('id') == 'hotel_search_outer') {
		var expiresDate = new Date();
		expiresDate += 1000*60*60;
		var baloonWidth = $('#cnt-top .char-chief .tip .tcnt').width();
		var baloonWidthNew = 360;
		var searchFormMoreShow = function() {
			$('.more-less-controls .more').hide();
			$('.hotel_search_more').show();
			$('#adults-list').show();
			$('.more-less-controls .less').css('display', 'block');
			$('#input-hotelname').focus();
			if ($('#searchFormOpenedStatus').length > 0) {
				$('#cnt-top .char-chief .tip .tcnt').width(baloonWidth);
				$('#search-more-text').remove();
			}
		};
		var searchFormMoreHide = function() {
			$('.more-less-controls .less').hide();
			$('.hotel_search_more').hide();
			$('#adults-list').hide();
			$('.more-less-controls .more').css('display', 'block');
			if ($('#searchFormOpenedStatus').length > 0) {
				setCookie('searchFormOpened', false, expiresDate);
				$('#cnt-top .char-chief .tip .tcnt').width(baloonWidthNew);
				$('#chief-baloon').after('<p id="search-more-text"><b>' + 'USE_ADVANCED_SEARCH'.translate() + '</b></p>');
			}
		};
		$('.more-less-controls .more').click(searchFormMoreShow);
		$('.more-less-controls .less').click(searchFormMoreHide);
		if ($('#searchFormOpenedStatus').length > 0) {
			var currentSearchFormOpened = getCookie('searchFormOpened');	
			var setSearchFormOpenedCookie = function() {
				if (currentSearchFormOpened == null) {
					setCookie('searchFormOpened', true, expiresDate);
				}
			}
			$('.navigation li').not('.disabled').find('a').click(setSearchFormOpenedCookie);
			$('.pager li').not('.active').find('a').click(setSearchFormOpenedCookie);
		
			if (currentSearchFormOpened == 'true') {
				searchFormMoreShow();
			} else if (currentSearchFormOpened == 'false') {
				searchFormMoreHide();
			}

		}
	}
});